const express = require('express')
const mysql = require('mysql')
// 创建路由对象
const user = express.Router()
// 引入数据库配置文件
const database = require('../database')
// 创建数据库的连接对象
const db = mysql.createPool(database)
user.use(express.json())
// 解析 application/x-www-form-urlencoded
user.use(express.urlencoded({ extended: false }));
//测试接口
user.post('/getMember',(req,res)=>{
    let sql='select * from t_member where memberPhone=? and password=?'
    db.query(sql,[req.body.memberPhone,req.body.password],(err,result)=>{
        if(err||!result.length){
            // console.log(err);
            res.send({
                success: false,
                msg: '失败'
            })
        }else{
            res.send({
                success: true,
                msg: '成功'
            })
        }
    })
})
module.exports=user;